package com.topscore.uke.mvp.model;

import com.topscore.uke.entities.MemberConsumpInfo;
import com.topscore.uke.entities.StaffInfoEntity;
import com.topscore.uke.entities.UserInfo;
import com.topscore.uke.mvp.contractors.GetStaffInfoContractor;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.network.retrofit.ApiService;
import com.topscore.uke.network.retrofit.HandleErrorSubscriber;
import com.topscore.uke.network.retrofit.NetClient;
import com.topscore.uke.utils.UserInfoManager;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by 71468 on 2017/10/18.
 */

public class GetTeamStaffInfoModel implements GetStaffInfoContractor, GetStaffInfoContractor.Model {

    private final Listener mListener;
    private final ApiService mService;

    public GetTeamStaffInfoModel(Listener listener) {
        this.mListener = listener;
        this.mService = NetClient.getInstance().net().create(ApiService.class);
    }

    @Override
    public void getInfo(String userId, String role) {
        mService.getUserInformation(userId,role)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse<StaffInfoEntity>>(mListener) {
                    @Override
                    public void onSuccess(BaseResponse<StaffInfoEntity> response) {
                        mListener.getInfoSuccess(response);
                    }
                });
    }
}
